import 'dart:nativewrappers/_internal/vm/lib/ffi_allocation_patch.dart';

import 'package:device_info_plus/device_info_plus.dart';

mixin DeviceInfoMixin {
  final deviceInfo = DeviceInfoPlugin();

  Future<BaseDeviceInfo> getDeviceInfo() {
    return deviceInfo.deviceInfo;
  }

  Future<AndroidDeviceInfo> getAndroidDeviceInfo() {
    return deviceInfo.androidInfo;
  }

  Future<IosDeviceInfo> getIosDeviceInfo() {
    return deviceInfo.iosInfo;
  }

  Future<void> deploy({
    Function(Map<String, dynamic> data)? onSuccess,
  }) async {
    final info = await getDeviceInfo();
    if (info is AndroidDeviceInfo) {
      onSuccess?.call({
        'model': info.model,
        'manufacturer': info.manufacturer,
        'brand': info.brand,
        'device': info.device,
        'product': info.product,
        'display': info.display,
        'version': info.version,
        'id': info.id,
        'board': info.board,
        'bootloader': info.bootloader,
        'hardware': info.hardware,
        'host': info.host,
        'tags': info.tags,
        'type': info.type,
        'isPhysicalDevice': info.isPhysicalDevice,
        'supported32BitAbis': info.supported32BitAbis,
        'supported64BitAbis': info.supported64BitAbis,
        'supportedAbis': info.supportedAbis,
        'serialNumber': info.serialNumber,
        'systemFeatures': info.systemFeatures,
      });
    }
    if (info is IosDeviceInfo) {}
  }
}
